﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;

namespace WebArchiveCopier.IO
{
	public class AdvancedWebClient : WebClient
	{
		private bool HeadOnly { get; set; }

		protected override WebRequest GetWebRequest(Uri address)
		{
			WebRequest req = base.GetWebRequest(address);
			if (HeadOnly && req.Method == "GET")
			{
				req.Method = "HEAD";
			}
			return req;
		}

		protected string GetContentType(Uri address)
		{
			HeadOnly = true;
			byte[] body = DownloadData(address);
			HeadOnly = false;
			return ResponseHeaders["content-type"];
		}
	}
}
